<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>表单提交</title>
</head>
<body>
  <select>
    <option value="grapefruit">葡萄柚</option>
    <option value="lime">酸橙</option>
    <option selected value="coconut">椰子</option>
    <option value="mango">芒果</option>
  </select>
  <div id="app"></div>
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <!-- 使用jsx需要babel转义 -->
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <!-- 使用babel需要申明type -->
  <script type="text/babel">
    const tag = document.getElementById('app')

    class NameFrom extends React.Component {
      constructor(props) {
        super(props)
        this.state = {
          value: '222'
        }
        this.handleChange = this.handleChange.bind(this)
        this.handleSubmit = this.handleSubmit.bind(this)
      }
      handleChange(event) {
        console.log('e----->',event.targrt,event)
        // 修改输入内容
        this.setState({
          value: event.target.value.toUpperCase()
        })
      }
      handleSubmit(e) {
        e.preventDefault()
        console.log(this.state)
        alert('提交的名字' + this.state.value)
      }
      render() {
        return (
          <form onSubmit={this.handleSubmit}>
            <label>
              名字：
              <textarea type='text' value={this.state.value} onChange={this.handleChange} />
            </label>
            <input type='submit' value='提交' />

          </form>
        )
      }
    }

    ReactDOM.render(
      <NameFrom />,
      tag
    )
  </script>
</body>
</html>